from mydsm5.odmantic.mongoDB_models import DisorderKind, MentalDisorder


class DisorderKindRepository:

    def __init__(self, engine):
        self.engine = engine

    async def get_disorder_kind_by_name(self, name: str) -> DisorderKind:
        scale = await self.engine.find_one(
            DisorderKind, DisorderKind.chinese_name == name)
        return scale

    async def get_all_disorder_kinds(self) -> list:
        disorder_kinds = await self.engine.find(
            DisorderKind, sort=DisorderKind.chinese_name)
        return disorder_kinds


class MentalDisorderRepository:

    def __init__(self, engine):
        self.engine = engine

    async def get_disorder_by_name(self, name: str) -> MentalDisorder:
        scale = await self.engine.find_one(
            MentalDisorder, MentalDisorder.chinese_name == name)
        return scale

    async def get_all_disorders(self) -> list:
        disorders = await self.engine.find(
            MentalDisorder, sort=MentalDisorder.chinese_name)
        return disorders
